const chatApp = window.chatApp;
chatApp.login();
document.getElementById("login-btn").onclick = function(){
    var username = document.getElementById("username").value;
    var password = document.getElementById("password").value;
    doLogin(username,password);
}

function doLogin(username,password){
    let data = "username=" + username + "&password=" +password;
    let json = JSON;
    stringify(data);
    ajax({
        url:"login.php",
        type:"POST",
        data:json,
        contentType:"application/json"
    }).then((ret)=>{
        let userData = JSON.
        parse(ret);
        let face = document.getElementById("face");
        face.src = userData.face;
        face.title = userData.username;
        charApp.showmain();
    },()=>{});
    /*setTimeout(()=>{
        if(username===password) chatApp.showMain();
        else alert("用户名密码不正确");
    },1000);*/
}